Calculator

Keep on top of your math with this JavaScript Calculator. (This calculator works erratically on PC Netscape platforms).



Discussion

This calculator stores all its numbers and operators in strings. It uses the JavaScript eval function to evaluate these expressions. For example, the result of eval("2 + 2") is 4. JavaScript can evaluate any string which uses valid JavaScript constructs; the statement eval("alert('hello')") is identical in execution to alert('hello').

Try it out. Tap on the [C] clear button, click in the text entry field, and delete the zero. Now type 2 + 2 directly into the Calculator's answer window and then press the [=] button. Try typing and evaluating these other expressions. Remember: [C]lear and erase the zero each time; also remember that JavaScript is case sensitive.

Copyright ©1998 by Charles River Media, All Rights Reserved